<template>
  <div class="app-container">
    <el-table
      :data="list"
      v-loading.body="listLoading"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="ID" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="名称">
        <template slot-scope="scope">
          <el-input v-model="scope.row.stuinfo.name"> </el-input>
        </template>
      </el-table-column>
      <el-table-column label="账户"  >
        <template slot-scope="scope">
          <el-input v-model="scope.row.stuinfo.account"> </el-input>
        </template>
      </el-table-column>
      <el-table-column label="密码"  >
        <template slot-scope="scope">
          <el-input disabled v-model="scope.row.stuinfo.password"> </el-input>
        </template>
      </el-table-column>
      <el-table-column label="所属班级"  >
        <template slot-scope="scope">
          <el-input disabled v-model="scope.row.classinfo.name"> </el-input>
        </template>
      </el-table-column>
      <el-table-column label="状态"  >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.stuinfo.status == 0" type="success">可用</el-tag>
          <el-tag v-else type="danger">不可用</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="created_at"
        label="操作"
        width="200"
      >
        <template slot-scope="scope">
          <el-button type="primary" size="mini">保存</el-button>
          <el-button v-if="scope.row.status == 0" type="danger" size="mini">关闭使用</el-button>
          <el-button v-else type="success" size="mini">开放使用</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getStudentList } from "@/api/doctor";

export default {
  data() {
    return {
      list: null,
      listLoading: true,
      listQuery:{
        currentpage:1,
        pagesize:20,
        name:"",
      }
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.listLoading = true;
      getStudentList(this.listQuery).then((response) => {
        console.log("get list success")
        this.list = response.info;
        this.listLoading = false;
      }).catch(err=>{
        this.listLoading = false;
      })
    },
    disable:function(e){
      console.log(e);
    }
  },
};
</script>
